﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Cinema_Ticketing_System.Models.Film
{
    /// <summary>
    /// 电影
    /// </summary>
    public class Films
    {
        CinemaDBEntities2 db = new CinemaDBEntities2();
        /// <summary>
        /// 根据电影编号获得电影信息
        /// </summary>
        /// <param name="filmId">电影编号</param>
        /// <returns></returns>
        public film_table GetFilmMsg(int filmId)
        {
            film_table film_Table1 = db.film_table.SingleOrDefault(X => X.filmid == filmId);


            return film_Table1;
        }

        /// <summary>
        /// 获取电影播放信息
        /// </summary>
        /// <param name="playid"></param>
        /// <returns></returns>
        public play_table GetPlayMsg(int playid)
        {
            play_table play_Table = db.play_table.SingleOrDefault(x=>x.playid==playid);

            return play_Table;
        }

        public play_table GetFilmidMsg(int filmId)
        {
            play_table play_Table = db.play_table.SingleOrDefault(x => x.filmid == filmId);

            return play_Table;
        }

        
        public int DeleteFilm(film_table film)
        {
            film_table film1 = film;
            //判断选择的是否处于未删除状态
            if (film1.release_status != 2)
            {
                return db.SaveChanges();
            } 
            //处于删除状态则返回异常状态
            return -99;

            
            
        }
    }
}